package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.CustomerStatementEnum;
import com.xbongbong.saas.enums.business.PaymentEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 客户对账单打印的明细的枚举码
 *
 */
@Getter
public enum PrintCustomerStatementDetailEnum {

    /**
     * 对账日期
     */
    CHECKING_DATE(CustomerStatementEnum.CHECKING_DATE.getAttr(), CustomerStatementEnum.CHECKING_DATE.getI18nAttrName(),0),
    /**
     * 类型
     */
    BUSINESS_TYPE(CustomerStatementEnum.BUSINESS_TYPE.getAttr(), CustomerStatementEnum.BUSINESS_TYPE.getI18nAttrName(), 1),
    /**
     * 对账单据
     */
    STATEMENT_ID(CustomerStatementEnum.STATEMENT_ID.getAttr(), CustomerStatementEnum.STATEMENT_ID.getI18nAttrName(),2),

    /**
     * 关联合同
     */
    CONTRACT_ID(CustomerStatementEnum.CONTRACT_ID.getAttr(), CustomerStatementEnum.CONTRACT_ID.getI18nAttrName(), 3),

    /**
     * 来源单据
     */
    SOURCE_ID(CustomerStatementEnum.SOURCE_ID.getAttr(), CustomerStatementEnum.SOURCE_ID.getI18nAttrName(), 4),


    PRODUCT(CustomerStatementEnum.PRODUCT.getAttr(), CustomerStatementEnum.PRODUCT.getI18nAttrName(), 5),
    /**
     * 应收金额
     */
    AMOUNT_RECEIVABLE(CustomerStatementEnum.AMOUNT_RECEIVABLE.getAttr(), CustomerStatementEnum.AMOUNT_RECEIVABLE.getI18nAttrName(),6),

    /**
     * 回款金额
     */
    AMOUNT_RECEIVED(CustomerStatementEnum.AMOUNT_RECEIVED.getAttr(), CustomerStatementEnum.AMOUNT_RECEIVED.getI18nAttrName(),7),

    /**
     * 核销金额
     */
    WRITE_OFF_AMOUNT(CustomerStatementEnum.WRITE_OFF_AMOUNT.getAttr(), CustomerStatementEnum.WRITE_OFF_AMOUNT.getI18nAttrName(),8),

    /**
     * 应收余额
     */
    BALANCE_RECEIVABLE(CustomerStatementEnum.BALANCE_RECEIVABLE.getAttr(), CustomerStatementEnum.BALANCE_RECEIVABLE.getI18nAttrName(),9),

    /**
     * 对账单展示：回款类型，针对应收款
     */
    PAYMENT_TYPE(CustomerStatementEnum.PAYMENT_TYPE.getAttr(),CustomerStatementEnum.PAYMENT_TYPE.getAttrName(),10),
    ;

    private String attr;
    private String name;
    private int sort;

    PrintCustomerStatementDetailEnum(String attr, String name, int sort) {
        this.attr = attr;
        this.name = name;
        this.sort = sort;
    }


    public static List<PrintCustomerStatementDetailEnum> getAllEnum() {
        List<PrintCustomerStatementDetailEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static PrintCustomerStatementDetailEnum getByAttr(String alias) {
        for (PrintCustomerStatementDetailEnum cacheCode : values()) {
            if (cacheCode.getAttr().equals(alias)) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
